using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

namespace Evaluation3
{
    public partial class SearchResult : System.Web.UI.Page
    {
        private long duration = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            FullTextSearch((SqlConnection)Application["myConn"], Request.QueryString["key"]);
        }

        public DataView FullTextSearch(SqlConnection conn, String key)
        {
            String sqlSelect = " select * from doanhnghiep where (tendoanhnghiep like '%@key%' ";
            sqlSelect = sqlSelect + " or namthanhlap like '%@key%' or chucnang like '%@key%' or info like '%@key%' )";

            SqlCommand cmd = new SqlCommand(sqlSelect, conn);
            cmd.Parameters.Add(new SqlParameter("@key", key));
            if (conn.State == ConnectionState.Closed) conn.Open();
            SqlDataReader rs = cmd.ExecuteReader();
            while (rs.Read())
            {
                Response.Write(rs[0]);
                Response.Write("<br/>");
            }

            conn.Close();

            return new DataView();


        }
    }
}
